/**
 * 
 */
package com.gfwy.proxy;

import java.util.List;


import com.gfwy.dao.ILinkDao;
import com.gfwy.dao.impl.LinkDaoImpl;
import com.gfwy.dbc.DatabaseConnection;
import com.gfwy.vo.Link;

/**
 * @author Administrator
 *
 */
public class LinkDaoProxy implements ILinkDao {
	ILinkDao dao = null;
	DatabaseConnection dbc = null;
	public LinkDaoProxy() {
		try {
			this.dbc = new DatabaseConnection();
		} catch (Exception e) {
			e.printStackTrace();
		}
		this.dao = new LinkDaoImpl(this.dbc.getConnection());
	}
	/* (non-Javadoc)
	 * @see com.hospital.dao.ILinkDao#doCreate(com.hospital.vo.Link)
	 */
	@Override
	public boolean doCreate(Link link) throws Exception {
		boolean flag = false;
		try {
			flag = this.dao.doCreate(link);
		} catch (Exception e) {
			throw e;
		} finally {
			this.dbc.close();
		}
		return flag;
	}

	/* (non-Javadoc)
	 * @see com.hospital.dao.ILinkDao#doUpdate(com.hospital.vo.Link)
	 */
	@Override
	public boolean doUpdate(Link link) throws Exception {
		boolean flag = false;
		try {
			flag = this.dao.doUpdate(link);
		} catch (Exception e) {
			throw e;
		} finally {
			this.dbc.close();
		}
		return flag;
	}

	/* (non-Javadoc)
	 * @see com.hospital.dao.ILinkDao#doDelete(int)
	 */
	@Override
	public boolean doDelete(int lid) throws Exception {
		boolean flag = false;
		try {
			flag = this.dao.doDelete(lid);
		} catch (Exception e) {
			throw e;
		} finally {
			this.dbc.close();
		}
		return flag;
	}

	/* (non-Javadoc)
	 * @see com.hospital.dao.ILinkDao#findAll(java.lang.String, int, int)
	 */
	@Override
	public List<Link> findAll(String keyWord, int startIndex, int count)
			throws Exception {
		List<Link> list = null;
		try {
			list = this.dao.findAll(keyWord, startIndex, count);
		} catch (Exception e) {
			throw e;
		} finally {
			this.dbc.close();
		}
		return list;
	}

	/* (non-Javadoc)
	 * @see com.hospital.dao.ILinkDao#findById(int)
	 */
	@Override
	public Link findById(int lid) throws Exception {
		Link link = null;
		try {
			link = this.dao.findById(lid);
		} catch (Exception e) {
			throw e;
		} finally {
			this.dbc.close();
		}
		return link;
	}

	/* (non-Javadoc)
	 * @see com.hospital.dao.ILinkDao#count(java.lang.String)
	 */
	@Override
	public int count(String keyWord) throws Exception {
		int count = 0;
		try {
			count = this.dao.count(keyWord);
		} catch (Exception e) {
			throw e;
		} finally {
			this.dbc.close();
		}
		return count;
	}

}
